package leetcode.剑指offer.剑指II;

import leetcode.剑指offer.pojo.ListNode;
import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2022/3/23 13:58
 * @description：
 */
public class 剑指_II_027_回文链表 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public boolean isPalindrome(ListNode head) {
            List<Integer> list = new ArrayList<>();
            while (head != null) {
                list.add(head.val);
                head = head.next;
            }
            for (int i = 0; i < list.size() / 2; i++) {
                if (list.get(i) != list.get(list.size() - 1 - i)) {
                    return false;
                }
            }
            return true;
        }
    }
}
